Range
Represents a generic range defined by a minimum and maximum value.
实现: IConvertible, IRange<T>, IRange, ICloneable
构造函数
public Range(T min, T max)
range = Range(min, max)
Initializes a new instance of the Range class with specified minimum and maximum values.
- min
- The minimum value of the range.
- max
- The maximum value of the range.
属性
public bool HasMaxValue { get; }
value = range.HasMaxValue
Gets a value indicating whether the range has a specified maximum value.
public bool HasMinValue { get; }
value = range.HasMinValue
Gets a value indicating whether the range has a specified minimum value.
public T Length { get; }
value = range.Length
Gets the difference between the maximum and minimum values of the range.
public T Max { get; set; }
value = range.Max
range.Max = value
Gets or sets the maximum value of the range.
public T Min { get; set; }
value = range.Min
range.Min = value
Gets or sets the minimum value of the range.
public IOperator<T> Operator { get; set; }
value = range.Operator
range.Operator = value
Gets or sets the operator used for arithmetic operations within the range.
方法
public override Range<T> Clone()
result = range.Clone()
Creates a new object that is a copy of the current instance.
返回值: A new object that is a copy of this instance.
public bool Contains(IRange<T> range)
result = range.Contains(range)
Determines whether the current range completely contains another range.
- range
- The range to check against.
返回值: true if the range is contained; otherwise, false.
public bool Contains(T value)
result = range.Contains(value)
Determines whether the specified value is within the current range.
- value
- The value to test.
返回值: true if the value is within the range; otherwise, false.
public override int GetHashCode()
result = range.GetHashCode()
Serves as the default hash function.
返回值: A hash code for the current object.
private void Init(T min, T max)
range.Init(min, max)
Initializes the range with the specified minimum and maximum values.
- min
- The minimum value.
- max
- The maximum value.
public IRange<T> Intersect(IRange<T> range)
result = range.Intersect(range)
Returns the intersection of the current range with another range.
- range
- The range with which to intersect.
返回值: A new IRange representing the overlap between the two ranges, or null if there is no intersection.
public Range<T> SubRange(T min, T max)
result = range.SubRange(min, max)
Creates a sub-range from the current range given the specified minimum and maximum values.
- min
- The minimum value of the sub-range.
- max
- The maximum value of the sub-range.
返回值: A new Range representing the sub-range.
public override string ToString()
result = range.ToString()
Returns a string representation of the tuple, with values separated by commas.
返回值: A string representing the tuple's values.